DUP Function: Copy file descriptorRelated header files: # include Function expression: int DUP (INT filedes );Parameter description: The DUP function parameter filedes indicates the file descriptor of the file to be copied.Return Value Description:
1. File descriptor in the kernel data structureBefore I go into specific dup/dup2, I think it's necessary to look at the file descriptor's pattern in the kernel. During the existence of a process, some files will be opened, which will return some
I. Files in Linux
There are four types of files: common files, directory files, link files, and device files.
1. Common files
Is the most commonly used file, including text files, shell scripts, binary executable and various types of data.
Ls-LH
the role of DUP and dup2DUP and dup2 are also two very useful calls that are used to copy the descriptor of a file. They are often used to redirect stdin, stdout, and stderr of processes. The prototypes for these two functions are as
DUP and dup2 are two very useful calls. They are used to copy the descriptor of a file. They are often used to redirect stdin, stdout, and stderr of processes. The original form of these two functions is as follows: # include int DUP (INT oldfd);
Transferred from: http://eriol.iteye.com/blog/1180624Transferred from: http://www.cnblogs.com/jht/archive/2006/04/04/366086.htmlDUP and dup2 are also two very useful calls that are used to copy the descriptor of a file. They are often used to
DUP and dup2 are two very useful calls. They are used to copy the descriptor of a file. They are often used to redirect stdin, stdout, and stderr processes. The two functions are prototype as follows:# IncludeInt DUP (INT oldfd );Int dup2 (INT oldfd,
1. Data Structure of file descriptors in the kernel
Before specifying DUP/dup2, I think it is necessary to first understand the form of file descriptors in the kernel.
When a process exists, some files are opened, and some file descriptors are
Resources:Http://www.tldp.org/LDP/lpg/node11.htmlhttp://blog.csdn.net/yeyuangen/article/details/6852682Http://blog.sina.com.cn/s/blog_65c5c5990100mx6d.htmlPipeline is a very important way of communication in Linux , is to connect the output of a
Both dup and dup2 can be used to copy an existing file descriptor. STDIN, STDOUT, and STDERR are often used to redirect processes.
Dup FunctionThe dup function is defined in . The original function is:
Int dup (int filedes );The function returns a
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.